﻿using UnityEngine;
using System.Collections;

public class NotificationManager : MonoBehaviour {
	
	public enum Type
	{
		NickName,
		Power,
		BarrierAvailable
	}
	
	public UILocalize loc;
	public Type type;
	public static NotificationManager instance;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void Awake()
	{
		instance = this;
		gameObject.SetActive(false);
	}
	
	void OnEnable()
	{
		TweenScale tween = TweenScale.Begin(this.gameObject, 0.5f, new Vector3(1,1,1));
		
		tween.method = UITweener.Method.EaseInOut;
		
		loc.key = type.ToString() + "Notification";
		
		loc.Localize();
		
	}	
	
	public void Show(Type notificationType, float duration)
	{
		if( !gameObject.activeInHierarchy)
		{
			type = notificationType;
			gameObject.SetActive(true);
			StartCoroutine(Remove(duration));
		}
	}
	
	public IEnumerator Remove(float duration)
	{
		yield return new WaitForSeconds(duration);
		
		TweenScale.Begin(this.gameObject, 0.5f, new Vector3(0,0,1));
		
		yield return new WaitForSeconds(0.5f);
		
		gameObject.SetActive(false);
		
	}
	
	
}
